package com.xtinno.dal.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xtinno.dal.dto.WorkflowBaseModel;
import com.xtinno.dal.mapper.WorkflowBaseMapper;
import com.xtinno.dal.service.IWorkflowBaseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xjj
 * @since 2025-06-10
 */
@Service
public class WorkflowBaseServiceImpl extends ServiceImpl<WorkflowBaseMapper, WorkflowBaseModel> implements IWorkflowBaseService {
    /**
     * 获取默认的大模型请求参数
     * @return
     */
    public JSONObject GetDefaultLlmParam(){
        Page<WorkflowBaseModel> page = new Page<>(1, 1); // 第一页，每页1条
        IPage<WorkflowBaseModel> resultPage = this.page(page, null);
        List<WorkflowBaseModel> records = resultPage.getRecords();
        if (!records.isEmpty()) {
            WorkflowBaseModel entity = records.get(0);
            return JSONObject.parseObject(entity.getCWfdLlmModelParamsDefault());
        }
        throw new RuntimeException("没有读取到默认的大模型请求参数或者参数有误");
    }
}
